package by.demchenko.sample.webapp.page.admin;

import by.demchenko.sample.datamodel.enums.UserType;
import by.demchenko.sample.webapp.app.BasicAuthenticationSession;
import by.demchenko.sample.webapp.app.WicketWebApplication;
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.link.Link;

@AuthorizeInstantiation("ADMIN")
public class BaseAdminPage extends WebPage {

    public BaseAdminPage() {
        super();

        add(new Link("students") {
            @Override
            public void onClick() {
                setResponsePage(new StudentsPage(UserType.STUDENT));
            }
        });

        add(new Link("teachers") {
            @Override
            public void onClick() {
                setResponsePage(new StudentsPage(UserType.TEACHER));
            }
        });

        add(new Link("courses") {
            @Override
            public void onClick() {
                setResponsePage(new CoursesPage());
            }
        });

        add(new Link("schedule") {
            @Override
            public void onClick() {
                setResponsePage(new SchedulePage());
            }
        });

        add(new Link("exitButton") {
            @Override
            public void onClick() {
                BasicAuthenticationSession.get().signOut(this);
                setResponsePage(new WicketWebApplication().getHomePage());
            }
        });

    }

}
